package com.yc.home.cloudindex.web;

import com.yc.bean.Result;
import com.yc.home.cloudindex.fegin.OtherAction;
import com.yc.home.cloudindex.fegin.OtherActionImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class IndexDo {

    @Autowired
    RestTemplate restTemplate;

    @RequestMapping("user")
    String user(){
        return restTemplate.getForObject(
                "http://cloud-user/user",
                String.class);
    }

    @RequestMapping("other")
    String other(){
        return restTemplate.getForObject(
                "http://cloud-other/other",
                String.class);
    }

    @Autowired
    OtherAction otherAction;

    @Autowired
    OtherActionImpl otherActionImpl;

    @RequestMapping("doquestion/getweekordernum")
    Result getweekordernum(@RequestParam("id") String id){
        Result result = otherAction.getweekordernum(id);
        otherActionImpl.setHotsCache(result);
        return result;
    }

    @RequestMapping("doquestion/getFiveQuestionall")
    Result getFiveQuestionall(){
        Result result = otherAction.getFiveQuestionall();
        otherActionImpl.setHotsCache1(result);
        return result;
    }

    @RequestMapping("doquestion/getFiveQuestion")
    Result getFiveQuestion(){
        Result result = otherAction.getFiveQuestion();
        otherActionImpl.setHotsCache2(result);
        return result;
    }





}
